﻿using UnityEngine;
using System.Collections;
using Newtonsoft.Json;

namespace Game.Global.Helper
{
	public static class JsonHelper  
	{

		//---------------------------------------------------------------------------
		//				Public area
		//---------------------------------------------------------------------------
		#region Public area

        /// <summary>
        /// 将字符串反序列化成对应物体
        /// </summary>
        /// 后期如果CS架构，将从打包后的格式中解包，无错才有物体返回
        public static T Deserialize<T>(string jsonString)
        {
            return JsonConvert.DeserializeObject<T>(jsonString);
        }

        /// <summary>
        /// 将物体序列化成字符串
        /// </summary>
        /// 后期如果是CS架构，将把该物体再打包成对应含错误信息的结构再序列化发出
        public static string Serialize(object obj)
        {
            return JsonConvert.SerializeObject(obj);
        }

		#endregion

	}
}